package com.lzit.smart_canteen.repository;

import com.lzit.smart_canteen.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserRepository extends JpaRepository<User,Integer> {
    @Query(value = "INSERT INTO t_user(name,password,num,valid) VALUE (?1,?2,?3,?4)",nativeQuery = true)
    public void addUser(String name, String  password, String num, int valid);
    @Query("SELECT u FROM t_user u WHERE u.num = ?1")
    User findUserByNum(String num);
    public List<User> findUsersByName(String name);
    @Query("SELECT u FROM t_user u WHERE u.id = ?1")
    public User findUserById(Integer id);
    @Query("SELECT u FROM t_user u WHERE u.valid = ?1")
    public List<User> findUserByValid(int valid);
}
